

package view;

/**
 *
 * @author RAMIN & NOORAMI
 */
public class StudentGUI extends javax.swing.JFrame{

    Boolean isStudent;      //flag variable to enable and disable certain function depending of the type of user (student or setter)
    

    public StudentGUI() {
        
        //add swing components and edit their properties
        initComponents();

        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.setLocationRelativeTo(null);   //center of screen
        
       
    }
    
    public void setTestTaker(Boolean isStudent){
        this.isStudent=isStudent;
        showButtons();
    }
    
    void showButtons(){
        btnPrevSection.setVisible(!isStudent);
        btnReturnEditor.setVisible(!isStudent);
    }
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        pnltests = new javax.swing.JPanel();
        lblSection = new javax.swing.JLabel();
        btnNextSection = new javax.swing.JButton();
        btnPrevSection = new javax.swing.JButton();
        btnReturnEditor = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        lblTime = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        lblTestName = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));
        setBounds(new java.awt.Rectangle(0, 22, 800, 800));

        jPanel1.setLayout(new java.awt.GridLayout(1, 0));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel2.setForeground(new java.awt.Color(204, 204, 204));

        pnltests.setBackground(new java.awt.Color(204, 204, 204));
        pnltests.setBorder(javax.swing.BorderFactory.createCompoundBorder(new javax.swing.border.MatteBorder(null), new javax.swing.border.MatteBorder(null)));
        pnltests.setLayout(new java.awt.GridLayout(0, 1));
        jScrollPane1.setViewportView(pnltests);

        lblSection.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        lblSection.setText("Section: ");

        btnNextSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/nextSec48.png"))); // NOI18N
        btnNextSection.setText("Next Section");
        btnNextSection.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        btnNextSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextSectionActionPerformed(evt);
            }
        });

        btnPrevSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/backSec48.png"))); // NOI18N
        btnPrevSection.setText("Previous Section");
        btnPrevSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrevSectionActionPerformed(evt);
            }
        });

        btnReturnEditor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/editView48.png"))); // NOI18N
        btnReturnEditor.setText("Return to editor");
        btnReturnEditor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturnEditorActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lblTime.setFont(new java.awt.Font("Lucida Grande", 1, 18)); // NOI18N
        lblTime.setText("time");
        jPanel3.add(lblTime);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/time64.png"))); // NOI18N

        jLabel2.setText("hh:mm:ss");

        jLabel3.setText("Time remaining");

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lblTestName.setFont(new java.awt.Font("Lucida Grande", 1, 24)); // NOI18N
        lblTestName.setText("Test");
        jPanel4.add(lblTestName);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/test_64.png"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(39, 39, 39))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 959, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(btnReturnEditor)
                                        .addGap(35, 35, 35)
                                        .addComponent(btnPrevSection)
                                        .addGap(18, 18, 18)
                                        .addComponent(btnNextSection)))
                                .addGap(19, 19, 19))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel3)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(18, 18, 18)
                                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(77, 77, 77)
                                        .addComponent(jLabel1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(28, 28, 28))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(lblSection, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel1))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel5)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(11, 11, 11)
                .addComponent(lblSection)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 387, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnNextSection)
                    .addComponent(btnPrevSection)
                    .addComponent(btnReturnEditor)))
        );

        jLabel4.setFont(new java.awt.Font("Lucida Grande", 1, 18)); // NOI18N
        jLabel4.setText("MELT System");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(85, 85, 85)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4)))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnNextSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextSectionActionPerformed
        
    }//GEN-LAST:event_btnNextSectionActionPerformed

    private void btnPrevSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrevSectionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnPrevSectionActionPerformed

    private void btnReturnEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturnEditorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnReturnEditorActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new StudentGUI().setVisible(true);
            }
        });
    }

    public javax.swing.JPanel getSectionPanel(){
        return pnltests;
    }

    public javax.swing.JButton getBtnNextSection(){
        return btnNextSection;
    }

    public javax.swing.JLabel getSectionName(){
        return lblSection;
    }

    
    public javax.swing.JLabel getTime(){
        return lblTime;
    }

    public javax.swing.JLabel getTestName(){
        return lblTestName;
    }
    
    public javax.swing.JButton getBtnPrevious(){
        return btnPrevSection;
    }
    
    public javax.swing.JButton getReturnToEditor(){
        return btnReturnEditor;
    }

    
    

    public void setTimer(javax.swing.JLabel timer){
        
        jPanel3.removeAll();                                        //removes existing labels in the panel
        timer.setFont(new java.awt.Font("Lucida Grande", 1, 18));   //sets the font
        jPanel3.add(timer);                                         //adds the new timmerLabel beeing passed
    }


    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnNextSection;
    private javax.swing.JButton btnPrevSection;
    private javax.swing.JButton btnReturnEditor;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblSection;
    private javax.swing.JLabel lblTestName;
    private javax.swing.JLabel lblTime;
    private javax.swing.JPanel pnltests;
    // End of variables declaration//GEN-END:variables

}
